import time
import unittest
from selenium import webdriver
from selenium.webdriver import Keys
from selenium.webdriver.common.by import By
from selenium.webdriver.firefox.service import Service


class UnittestFireFoxDriver(unittest.TestCase):
    """
        driver 代表的是 浏览器 驱动对象
    """
    driver = None

    @classmethod
    def setUpClass(cls) -> None:
        cls.service = Service(executable_path='../day01/driver_exe/geckodriver.exe')
        cls.driver = webdriver.Firefox(service=cls.service)

    def test_element_close_quit(self):
        """八大元素定位方式 ：id"""
        self.driver.get('https://www.baidu.com')
        self.driver.find_element(By.XPATH, "/html/body/div[1]/div[1]/div[5]/div/div/div[3]/ul/li[1]/a/span[2]").click()

        time.sleep(5)

    @classmethod
    def tearDownClass(cls) -> None:
        # cls.driver.close() # 只会关掉某一个
        cls.driver.quit()  # 关闭所有的标签页 以及 浏览器
        pass


if __name__ == '__main__':
    pass
